<!DOCTYPE html>
<html lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="古 文">



<meta name="description" content="一、简介 ​         这里以glib的2.63.0版本，QNX系统的版本是：6.6 。这里是为了编译gstreamer的依赖库，也就是说最终目标，是将gstreamer移植到QNX6.6系统上。 我选择的是gstreamer 1.16，他需要的glib版本是2.40以上，因此就索性使用最新的glib版本。 编译用的host系统是Ubuntu18.04。">
<meta name="keywords" content="多媒体,qnx,移植,glib">
<meta property="og:type" content="article">
<meta property="og:title" content="gstreamer移植qnx(二)：移植glib2.6.3">
<meta property="og:url" content="http://xuanwolanxue.gitee.io/posts/50488.html">
<meta property="og:site_name" content="同好斋">
<meta property="og:description" content="一、简介 ​         这里以glib的2.63.0版本，QNX系统的版本是：6.6 。这里是为了编译gstreamer的依赖库，也就是说最终目标，是将gstreamer移植到QNX6.6系统上。 我选择的是gstreamer 1.16，他需要的glib版本是2.40以上，因此就索性使用最新的glib版本。 编译用的host系统是Ubuntu18.04。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-02-20T13:00:25.360Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="gstreamer移植qnx(二)：移植glib2.6.3">
<meta name="twitter:description" content="一、简介 ​         这里以glib的2.63.0版本，QNX系统的版本是：6.6 。这里是为了编译gstreamer的依赖库，也就是说最终目标，是将gstreamer移植到QNX6.6系统上。 我选择的是gstreamer 1.16，他需要的glib版本是2.40以上，因此就索性使用最新的glib版本。 编译用的host系统是Ubuntu18.04。">

<link rel="apple-touch-icon" href="/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="同好斋" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>gstreamer移植qnx(二)：移植glib2.6.3 | 同好斋</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?778ff23279d4dd12f6287e98750f2d86";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head></html>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/Minions.jpeg" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">古 文</a></h1>
        </hgroup>

        
        <p class="header-subtitle">同好斋</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="">
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class="no-result">No results found <i class="fa fa-spinner fa-pulse"></i></p>
        


        
		
        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
					<br>
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/categories/">分类</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/download/">下载</a></li>
                        
                            <li><a href="/tags/">标签</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <br>
                    <br>
                    <br>
                    <br>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">喜欢软件，爱好硬件的嵌入式工程师</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">古 文</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/Minions.jpeg" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">古 文</a></h1>
            </hgroup>
            
            <p class="header-subtitle">同好斋</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/categories/">分类</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/download/">下载</a></li>
                
                    <li><a href="/tags/">标签</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" target="_blank" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" target="_blank" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" target="_blank" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" target="_blank" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我">
</nav>
      <div class="body-wrap"><article id="post-多媒体_gstreamer移植qnx(2)移植glib2.63到qnx" class="article article-type-post" itemscope="" itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/posts/50488.html" class="article-date">
      <time datetime="2020-02-20T07:10:12.988Z" itemprop="datePublished">2020-02-20</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      gstreamer移植qnx(二)：移植glib2.6.3
    </h1>
  

        
			<div style="margin-top:10px;">
    <span class="post-time">
      <span class="post-meta-item-icon">
        <i class="fa fa-keyboard-o"></i>
        <span class="post-meta-item-text">  字数统计: </span>
        <span class="post-count">1.3k 字</span>
      </span>
    </span>

    <span class="post-time">
      &nbsp; | &nbsp;
      <span class="post-meta-item-icon">
        <i class="fa fa-hourglass-half"></i>
        <span class="post-meta-item-text">  阅读时长: </span>
        <span class="post-count">6 分</span>
      </span>
    </span>

    
        <span id="busuanzi_container_page_pv">
          &nbsp; | &nbsp;  本文总阅读量: <span id="busuanzi_value_page_pv"></span> 次
        </span>
    
</div>

        
      </header>
      
      <div class="article-info article-info-post">
        
          <br>
          <br>
        
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/多媒体系列/">多媒体系列</a><a class="article-category-link" href="/categories/多媒体系列/gstreamer移植qnx/">gstreamer移植qnx</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/glib/">glib</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/qnx/">qnx</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/多媒体/">多媒体</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/移植/">移植</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1>一、简介</h1>
<p>​         这里以glib的2.63.0版本，QNX系统的版本是：6.6 。这里是为了编译gstreamer的依赖库，也就是说最终目标，是将gstreamer移植到QNX6.6系统上。 我选择的是gstreamer 1.16，他需要的glib版本是2.40以上，因此就索性使用最新的glib版本。 编译用的host系统是Ubuntu18.04。</p>
<a id="more"></a> 
<h1>二、准备cross-file</h1>
<p>​        因为最新的glib其构建系统是使用的meson， 而我们这边是要交叉编译，所以需要准备一个cross-file的来配置交叉编译工具链</p>
<h2 id="2-1-填写工具链">2.1 填写工具链</h2>
<p>​        首先是需要填写CPU和系统信息，以及工具链信息， 顺便还可以填写编译完成之后，安装的目录，其内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">[host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<h2 id="2-2-填写编译flag信息">2.2 填写编译flag信息</h2>
<p>​         第一个就是需要定义一个 _QNX_SOURCE宏，不然在编译和POSIX thread相关的部分时，就会出现“error: #error POSIX Scheduling needs P1003.1b-1993 or later” 这类似的错误。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = []</span><br></pre></td></tr></table></figure>
<p>​          修改之后的完整版cross-file文件，qnx_arm.txt如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = []</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<h1>三、 修改meson.build</h1>
<p>​        因为某些特性，qnx6.6的toolchain里面没有，比如xattr， 因此这里需要修改meson的option选项，这里有两种方式：</p>
<ul>
<li>直接在meson的命令行参数，以 -Dxattr=false的方式进</li>
<li>修改glib里面的meson.build文件里面default_options部分</li>
</ul>
<p>​       这里为了方便，就选择了修改meson.build 文件，免得每次敲命令 都要带一长串参数。 当然，也可以把这个配置过程写到一个shell脚本里面。</p>
<p>​      修改后的default_options如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">default_options : [</span><br><span class="line">  'buildtype=release',</span><br><span class="line">  'warning_level=1',</span><br><span class="line">  'c_std=gnu99',</span><br><span class="line">  'xattr=false',</span><br><span class="line">  'force_posix_threads=true',</span><br><span class="line">  'libmount=false'</span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<p>​      qnx的libintl没有ngettext这个函数，因此需要使用glib自带的libintl库，</p>
<p>​       修改前的原始版本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span> First check in libc, fallback to libintl, and as last chance build</span><br><span class="line"><span class="meta">#</span> proxy-libintl subproject.</span><br><span class="line"><span class="meta">#</span> FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible</span><br><span class="line"><span class="meta">#</span> implementations. This could be extended if issues are found in some platforms.</span><br><span class="line">if cc.has_function('ngettext')</span><br><span class="line">  libintl = []</span><br><span class="line">  have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')</span><br><span class="line">else</span><br><span class="line">  libintl = cc.find_library('intl', required : false)</span><br><span class="line">  if not libintl.found()</span><br><span class="line">    libintl = subproject('proxy-libintl').get_variable('intl_dep')</span><br><span class="line">    have_bind_textdomain_codeset = true  # proxy-libintl supports it</span><br><span class="line">  else</span><br><span class="line">    have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',</span><br><span class="line">                                                  dependencies : libintl)</span><br><span class="line">  endif</span><br><span class="line">endif</span><br></pre></td></tr></table></figure>
<p>​        修改之后的版本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span> First check in libc, fallback to libintl, and as last chance build</span><br><span class="line"><span class="meta">#</span> proxy-libintl subproject.</span><br><span class="line"><span class="meta">#</span> FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible</span><br><span class="line"><span class="meta">#</span> implementations. This could be extended if issues are found in some platforms.</span><br><span class="line">if cc.has_function('ngettext')</span><br><span class="line">  libintl = []</span><br><span class="line">  have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')</span><br><span class="line">else</span><br><span class="line"><span class="meta">  #</span>libintl = cc.find_library('intl', required : false)</span><br><span class="line"><span class="meta">  #</span>if not libintl.found()</span><br><span class="line">    libintl = subproject('proxy-libintl').get_variable('intl_dep')</span><br><span class="line">    have_bind_textdomain_codeset = true  # proxy-libintl supports it</span><br><span class="line"><span class="meta">  #</span>else</span><br><span class="line"><span class="meta">  #</span>  have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',</span><br><span class="line"><span class="meta">  #</span>                                                 dependencies : libintl)</span><br><span class="line"><span class="meta">  #</span>endif</span><br><span class="line">endif</span><br></pre></td></tr></table></figure>
<h1>四、修改 gio目录下的内容</h1>
<h2 id="4-1-修改gio目录下的meson-build">4.1 修改gio目录下的meson.build</h2>
<p>​        因为qnx里面没有libresolv，也没有libbind， res_query函数是在libsocket库里面。因此需要修改gio目录下的meson.build文件。</p>
<p>原始内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">if host_system != 'windows'</span><br><span class="line"><span class="meta">  #</span> res_query()</span><br><span class="line">  res_query_test = '''#include &lt;resolv.h&gt;</span><br><span class="line">                      int main (int argc, char ** argv) &#123;</span><br><span class="line">                        return res_query("test", 0, 0, (void *)0, 0);</span><br><span class="line">                      &#125;'''</span><br><span class="line">  res_query_test_full = '''#include &lt;sys/types.h&gt;</span><br><span class="line">                           #include &lt;netinet/in.h&gt;</span><br><span class="line">                           #include &lt;arpa/nameser.h&gt;</span><br><span class="line">                        ''' + res_query_test</span><br><span class="line">  if not cc.links(res_query_test_full, name : 'res_query()')</span><br><span class="line">    if cc.links(res_query_test_full, args : '-lresolv', name : 'res_query() in -lresolv')</span><br><span class="line">      network_libs += [ cc.find_library('resolv') ]</span><br><span class="line">      network_args += [ '-lresolv' ]</span><br><span class="line">    elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')</span><br><span class="line">      network_libs += [ cc.find_library('bind') ]</span><br><span class="line">      network_args += [ '-lbind' ]</span><br><span class="line">    else</span><br><span class="line">      error('Could not find res_query()')</span><br><span class="line">    endif</span><br><span class="line">  endif</span><br><span class="line"></span><br><span class="line"><span class="meta">  #</span> socket()</span><br><span class="line">  socket_test = '''#include &lt;sys/types.h&gt;</span><br><span class="line">                   #include &lt;sys/socket.h&gt;</span><br><span class="line">                   int main (int argc, char ** argv) &#123;</span><br><span class="line">                     return socket(1, 2, 3);</span><br><span class="line">                   &#125;'''</span><br><span class="line">  if not cc.links(socket_test, name : 'socket()')</span><br><span class="line">    if cc.links(socket_test, args : '-lsocket', name : 'socket() in -lsocket')</span><br><span class="line">      network_libs += [ cc.find_library('socket') ]</span><br><span class="line">      network_args += [ '-lsocket' ]</span><br><span class="line">    else</span><br><span class="line">      error('Could not find socket()')</span><br><span class="line">    endif</span><br><span class="line">  endif</span><br></pre></td></tr></table></figure>
<p>修改之后如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">if host_system != 'windows'</span><br><span class="line"><span class="meta">  #</span> res_query()</span><br><span class="line">  res_query_test = '''#include &lt;resolv.h&gt;</span><br><span class="line">                      int main (int argc, char ** argv) &#123;</span><br><span class="line">                        return res_query("test", 0, 0, (void *)0, 0);</span><br><span class="line">                      &#125;'''</span><br><span class="line">  res_query_test_full = '''#include &lt;sys/types.h&gt;</span><br><span class="line">                           #include &lt;netinet/in.h&gt;</span><br><span class="line">                           #include &lt;arpa/nameser.h&gt;</span><br><span class="line">                        ''' + res_query_test</span><br><span class="line">  if not cc.links(res_query_test_full, name : 'res_query()')</span><br><span class="line">    if cc.links(res_query_test_full, args : '-lsocket', name : 'res_query() in -lsocket')</span><br><span class="line">      network_libs += [ cc.find_library('socket') ]</span><br><span class="line">      network_args += [ '-lsocket' ]</span><br><span class="line">    elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')</span><br><span class="line">      network_libs += [ cc.find_library('bind') ]</span><br><span class="line">      network_args += [ '-lbind' ]</span><br><span class="line">    else</span><br><span class="line">      error('Could not find res_query()')</span><br><span class="line">    endif</span><br><span class="line">  endif</span><br><span class="line"></span><br><span class="line"><span class="meta">  #</span> socket()</span><br><span class="line">  socket_test = '''#include &lt;sys/types.h&gt;</span><br><span class="line">                   #include &lt;sys/socket.h&gt;</span><br><span class="line">                   int main (int argc, char ** argv) &#123;</span><br><span class="line">                     return socket(1, 2, 3);</span><br><span class="line">                   &#125;'''</span><br><span class="line">  if not cc.links(socket_test, name : 'socket()')</span><br><span class="line">    if cc.links(socket_test, args : '-lsocket', name : 'socket() in -lsocket')</span><br><span class="line">      network_libs += [ cc.find_library('socket') ]</span><br><span class="line">      network_args += [ '-lsocket' ]</span><br><span class="line">    else</span><br><span class="line">      error('Could not find socket()')</span><br><span class="line">    endif</span><br><span class="line">  endif</span><br></pre></td></tr></table></figure>
<h2 id="4-2-修改gunixmounts-c">4.2 修改gunixmounts.c</h2>
<p>​        因为glib没有实现qnx平台的 _g_get_unix_mounts 和 _g_get_unix_mount_points 以及get_mtab_monitor_file 函数，因此编译会出现如下错误：</p>
<blockquote>
<p>…/gio/gunixmounts.c:954:2: error: #error No _g_get_unix_mounts() implementation for system<br>
…/gio/gunixmounts.c:1477:2: error: #error No g_get_mount_table() implementation for system</p>
</blockquote>
<p>​        因此需要在 954行和1477行添加qnx版本的的实现，其实也不是实现，就是留个空，代码如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//在954行添加</span></span><br><span class="line"><span class="comment">/* Common code &#123;&#123;&#123;2 */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">elif</span> defined(__QNX__)</span></span><br><span class="line"><span class="keyword">static</span> GList* _g_get_unix_mounts (<span class="keyword">void</span>)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span>* <span class="title">get_mtab_monitor_file</span> <span class="params">(<span class="keyword">void</span>)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">error</span> No _g_get_unix_mounts() implementation for system</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">//在1477行添加</span></span><br><span class="line"><span class="comment">/* Common code &#123;&#123;&#123;2 */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">elif</span> defined(__QNX__)</span></span><br><span class="line"><span class="keyword">static</span> GList * _g_get_unix_mount_points (<span class="keyword">void</span>)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">error</span> No g_get_mount_table() implementation for system</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br></pre></td></tr></table></figure>
<h1>五、编译过程</h1>
<ul>
<li>新建build目录并进入build目录：</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mkdir build</span><br><span class="line">cd build</span><br></pre></td></tr></table></figure>
<ul>
<li>meson配置</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">meson .. --cross-file ../qnx_arm.txt</span><br></pre></td></tr></table></figure>
<ul>
<li>ninja编译和安装</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ninja</span><br><span class="line">ninja install</span><br></pre></td></tr></table></figure>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/posts/50488.html">gstreamer移植qnx(二)：移植glib2.6.3</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">古 文</a></p>
        <p><span>发布时间:</span>2020-02-20, 15:10:12</p>
        <p><span>最后更新:</span>2020-02-20, 21:00:25</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/posts/50488.html" title="gstreamer移植qnx(二)：移植glib2.6.3">http://xuanwolanxue.gitee.io/posts/50488.html</a>
            <span class="copy-path" data-clipboard-text="原文: http://xuanwolanxue.gitee.io/posts/50488.html　　作者: 古 文" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target="_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/posts/4046.html">
                    gstreamer移植qnx(三)：libgstreamer 移植
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/posts/28659.html">
                    gstreamer移植qnx(四)：编译gstreamer插件
                </a>
            </div>
        
    </nav>

  
  
    
    <div style="padding: 0; margin: 20px auto; width: 90%; text-align: center;">
      <br>
      <div>有钱的捧个钱场，1元2元1毛2毛都行，您的支持将鼓励我继续创作！</div>
      <br>
      <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
        <div class="btn btn-pay">打赏支持</div>
      </button>
      <br>
      <br>
      <div id="QR" style="display: none;">
        
          <div id="wechat" style="display: inline-block;">
            <img id="wechat_qr" src="/img/wechat-reward-qr.png" alt="古 文 WeChat Pay">
            <p>微信打赏</p>
          </div>
        
        
          <div id="alipay" style="display: inline-block">
            <img id="alipay_qr" src="/img/alipay-reward-qr.png" alt="古 文 Alipay">
            <p>支付宝打赏</p>
          </div>
        
        <br>
        <br>
      </div>
    </div>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">1.</span> <span class="toc-text">一、简介</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">2.</span> <span class="toc-text">二、准备cross-file</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1-填写工具链"><span class="toc-number">2.1.</span> <span class="toc-text">2.1 填写工具链</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-填写编译flag信息"><span class="toc-number">2.2.</span> <span class="toc-text">2.2 填写编译flag信息</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">3.</span> <span class="toc-text">三、 修改meson.build</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">4.</span> <span class="toc-text">四、修改 gio目录下的内容</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#4-1-修改gio目录下的meson-build"><span class="toc-number">4.1.</span> <span class="toc-text">4.1 修改gio目录下的meson.build</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-2-修改gunixmounts-c"><span class="toc-number">4.2.</span> <span class="toc-text">4.2 修改gunixmounts.c</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">5.</span> <span class="toc-text">五、编译过程</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-6 i,
        .toc-level-6 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"gstreamer移植qnx(二)：移植glib2.6.3　| 同好斋　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
		<section id="comments" style="margin: 2em; padding: 2em; background: rgba(255, 255, 255, 0.5)">
    <div id="vcomment" class="comment"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@1.2.0-beta1/dist/Valine.min.js"></script>
    <script>
      new Valine({
        el: '#vcomment',
        notify: 'true',
        verify: 'true',
        app_id: "jGY8jU1Gd1LKJ1meqfpUrpfp-gzGzoHsz",
        app_key: "LnXY7e40Vnir0zsqU62K1MNA",
        placeholder: "评论",
        avatar: "mp"
      });
    </script>
</section>
	
	




    <div class="scroll" id="post-nav-button">
        
            <a href="/posts/4046.html" title="上一篇: gstreamer移植qnx(三)：libgstreamer 移植">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/posts/28659.html" title="下一篇: gstreamer移植qnx(四)：编译gstreamer插件">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/64143.html">repo安装与简单使用</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4046.html">gstreamer移植qnx(三)：libgstreamer 移植</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/50488.html">gstreamer移植qnx(二)：移植glib2.6.3</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/28659.html">gstreamer移植qnx(四)：编译gstreamer插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/30680.html">gstreamer移植qnx(五)：编写audio sink和video sink插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4138.html">gstreamer移植qnx(一)：概览篇</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/3250.html">c印记</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/56107.html">因为爱情</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2018-2020 古 文
                <br><br>
                <br>同好斋小网站<br>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_uv">
                      您是第 <span id="busuanzi_value_site_uv"></span> 位小伙伴
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        本站总访问量 <span id="busuanzi_value_site_pv"></span> 次
                    </span>
                
                <span>| </span>
                <span class="post-count">  已经写了 14.2k 字啦</span>
            </div>
        
        <br>
        <span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
        <script>
            var now = new Date(); 
            function createtime(){ var grt= new Date("12/19/2018 12:49:00");//此处修改你的建站时间或者网站上线时间 
            now.setTime(now.getTime()+250); 
            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); 
            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); 
            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); 
            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} 
            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); 
            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} 
            document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 "; 
            document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒"; } 
            setInterval("createtime()",250);
        </script>
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        $("a[target=_blank]").removeAttr("target");
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>




	<script type="text/javascript" src="/resources/love.js"></script>
	<script type="text/javascript" src="/resources/float.js"></script>
	<script type="text/javascript" src="/resources/typewriter.js"></script>
	<script type="text/javascript" color="0,104,183" opacity="1" zindex="-1" count="50" src="/resources/particle.js"></script>


  </div>
<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-100},"mobile":{"show":false},"react":{"opacityDefault":0.5,"opacityOnHover":0.2},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>